#include "student.h"
#include <cstring>
#include <iostream>

// Student::Student() : id(0), name() {}

Student::Student(int id, const std::string &name) : id(id), name(name) {}

// Student::Student(const Student &s):id(s.id), name(s.name){}

// Student::~Student()
// {
// }

void Student::Free(void *p)
{
    Student *s = (Student *)p;
    delete s;
}

void Student::print(void *p)
{
    Student *s = (Student *)p;
    std::cout << "学生学号" << s->id << " " << "学生姓名" << s->name << std::endl;
}

int Student::compare(void *p1, void *p2)
{
    Student *s1 = (Student *)p1;
    Student *s2 = (Student *)p2;
    return s1->id - s2->id;
    // return s1->name.compare(s2->name);
}

bool Student::AllCompare(void *p1, void *p2)
{
    Student *s1 = (Student *)p1;
    Student *s2 = (Student *)p2;
    // return ;
    return s1->name == s2->name && s1->id == s2->id;
}

ElementType Student::Copy(void *p)
{
    Student *s = (Student *)p;
    return s = new Student(s->id, s->name);
}
